<style>
    span{margin: 3px;}
</style>
<br/>
<form action="default/acl/add" method="post">
    <span>URL</span><span><?php echo $this->formText('url',null,array('style'=>'width:400px')); ?></span>
    <span>Perfil</span><span><?php echo $this->formSelect('role',null,null,$this->roles); ?></span>
    <span><?php echo $this->formSubmit('save', 'Salvar', array('class' => 'btn primary'));?></span>
</form>
<br />
<form action="default/acl/save" method="post">
    <?php foreach ($this->data as $module => $controllers):?>
        <div class="acl">
            <?php foreach ($controllers as $controller => $actions):?>
                <div class="toggle" style="border-bottom: 1px dotted #ddd; margin-bottom: 10px; padding-bottom: 5px; cursor: pointer;">
                    <strong><?php echo $module.' / '.$controller.' / '; ?></strong>
                </div>
                <div class="list" style="display: none; margin-left: 10px; margin-bottom: 20px;">
                    <table class="item">
                            <?php foreach ($actions as $action => $roles): ?>
                                    <?php $name = "data[$module][$controller][$action]"; ?>
                                    <tr>
                                        <td><?php echo $module.' / '.$controller.' / '.$action;?></td>
                                        <td>
                                            <span><?php echo $this->formText($name, $roles, array('style'=>'width:400px;'));?></span>
                                            <span><a class="btn" href="#">Excluir</a></span>
                                        </td>
                                    </tr>
                            <?php endforeach;?>
                    </table>
                </div>
            <?php endforeach;?>
        </div>
    <?php endforeach;?>
    <?php echo $this->formSubmit('save', 'Salvar', array('class' => 'btn primary'));?>
</form>
<script type="text/javascript">
    $('.toggle').click(function(){
        $(this).next().slideToggle('fast');
    });

    $('.item a').click(function(){
        if (confirm('Deseja realmente excluir esta permissão?')) {
            $(this).parent().parent().remove();
        }
        return false;
    });
</script>